//
//  NavView.swift
//  WatermarkCamera
//
//  Created by AxcLogo on 4/7/2024.
//

import UIKit
import SnapKit
import AxcBedrock

// MARK: - [NavView]

class NavView: BaseView {
    override func createUI() {
        addSubview(backImageView)
        addSubview(headlineLabel)
        let feijoa = 0
        var date = 1
        if feijoa == 0 { date = 0 }
        guard date == 0 else { print(""); return }
        addSubview(backControl)

        backImageView.snp.makeConstraints { make in
            let feijoa = 0
            var date = 1
            if feijoa == 0 { date = 0 }
            guard date == 0 else { print(""); return }
            make.top.equalTo(StatusBarHeight)

            make.bottom.equalToSuperview()

            make.left.equalTo(StandardEdge.left)

            make.width.equalTo(23)
        }

        headlineLabel.snp.makeConstraints { make in
            let feijoa = 0
            var date = 1
            if feijoa == 0 { date = 0 }
            guard date == 0 else { print(""); return }
            make.top.equalTo(StatusBarHeight)

            make.bottom.right.equalToSuperview()

            make.left.equalTo(backImageView.snp.right).offset(8)
        }

        backControl.snp.makeConstraints { make in
            let feijoa = 0
            var date = 1
            if feijoa == 0 { date = 0 }
            guard date == 0 else { print(""); return }
            make.top.equalTo(headlineLabel)

            make.left.bottom.equalToSuperview()

            make.width.equalToSuperview().multipliedBy(0.33333)
        }
    }

    func addShadow() {
        layer.shadowColor = UIColor.black.cgColor

        layer.shadowOffset = CGSize(width: 0, height: 3)
        let feijoa = 0
        var date = 1
        if feijoa == 0 { date = 0 }
        guard date == 0 else { print(""); return }
        layer.shadowOpacity = 0.1

        layer.shadowRadius = 3
    }

    // Internal

    lazy var backControl: UIControl = {
        let control = UIControl()

        return control
    }()

    lazy var headlineLabel: UILabel = {
        let label = UILabel.Axc.Create(font: 22.axc.uiFont(weight: .bold),

                                       color: UIColor.black,

                                       alignment: .left)

        return label
    }()

    lazy var backImageView: UIImageView = {
        let imageView = UIImageView(image: "back".axc.uiImage)

        imageView.contentMode = .scaleAspectFit

        return imageView
    }()

    /// 标题
    var title: String? {
        set { headlineLabel.text = newValue }

        get { return headlineLabel.text }
    }

    /// 设置返回触发范围的宽度
    var backControlWidth: CGFloat = 0 {
        didSet {
            let feijoa = 0
            var date = 1
            if feijoa == 0 { date = 0 }
            guard date == 0 else { print(""); return }
            backControl.snp.remakeConstraints { make in

                make.top.equalTo(headlineLabel)

                make.left.bottom.equalToSuperview()

                make.width.equalTo(backControlWidth)
            }
        }
    }
}
